home *** CD-ROM | disk | FTP | other *** search
- Path: stc06.ctd.ornl.gov!msr!kennel
- From: kennel@msr.epm.ornl.gov (Matt Kennel)
- Newsgroups: comp.lang.c++,comp.lang.c
- Subject: Re: Performance: C vs. C++
- Date: 15 Feb 1996 22:36:13 GMT
- Organization: Oak Ridge National Lab, Oak Ridge, TN
- Message-ID: <4g0cgt$a3l@stc06.ctd.ornl.gov>
- References: <30F6BAAC.12B5@iastate.edu> <4da9pn$a45@news.bridge.net> <AUSTERN.96Feb15134314@isolde.mti.sgi.com>
- NNTP-Posting-Host: msr.epm.ornl.gov
- X-Newsreader: TIN [version 1.2 PL2]
-
- Matt Austern (austern@isolde.mti.sgi.com) wrote:
- > In article <4fvr7k$a3l@stc06.ctd.ornl.gov> kennel@msr.epm.ornl.gov (Matt Kennel) writes:
-
- > > > What is a "dispatched pointer"?
- > >
- > > In C++ it would be a pointer to a base class which has 'virtual members',
- > > where the particular function called is chosen by the actual run-time
- > > type.
- > >
- > > In C++, if you have a pointer, then it is always conceivably dispatched,
- > > unless everything in the class is declared "static".
- > >
- > > So here "reference semantics" (going through a pointer, a storage area
- > > potentially aliased) are joined with "dispatchability".
-
- > That's not quite true. In C++, a function call is dispatched only if
- > the function is declared as virtual in the base class. You don't have
- > to make any special declaration of a function to make it
- > non-dispatched; you simply have to avoid doing anything special.
- > Declaring a function to be static is something else entirely.
-
- Sorry. I apologize for the mistake.
-
- I still think it's awkward that the maker of the class needs to
- determine what is dispatched and what is not; I prefer the user
- getting the choice.
-
- > And if you do have a pointer to a polymorphic class, and you want to
- > call a virtual function and ensure that you're calling the base
- > class's version, that's actually possible: instead of writing
- > base_pointer->f(), you write base_pointer->base::f(). The syntax
- > is ugly, to be sure, but it doesn't bother me that you have to use
- > ugly syntax for such a rare operation.
-
- Does it work with []??
-
- I.e.
-
- MyMatrix x;
-
- x[3][2] = 4;
-
- That was a problem we sometimes ran into in C++ vs. Sather. We found
- that in compiling Sather it is crucial that any array operations
- not ever be dispatched inside loops so that they could be inlined. Only
- then could strength reductions be applied, and then only if the array pointer
- could be proven to be a loop constant.
-
- Typically available C++ matrix classes were not able to do this on
- the compilers we had.
-
-
-
- > --
- > Matt Austern
- > SGI: MTI Compilers Group
- > austern@isolde.mti.sgi.com
-